package com.varian.system.listener;

import com.varian.system.service.ISysTaskService;
import com.varian.task.constant.TaskConstant;
import com.varian.task.model.TaskCreateModel;
import com.varian.task.model.TaskUpdateModel;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author ben
 * @since 2024/12/11
 */
@Component
@RequiredArgsConstructor
public class TaskProcessListener {

    private final ISysTaskService taskService;

    @RabbitListener(queues = {TaskConstant.QUEUE_TASK_CREATE})
    public void onCreateMessage(TaskCreateModel taskCreateModel) {
        taskService.processCreateMessage(taskCreateModel);
    }

    @RabbitListener(queues = {TaskConstant.QUEUE_TASK_UPDATE})
    public void onUpdateMessage(TaskUpdateModel taskUpdateModel) {
        taskService.processUpdateMessage(taskUpdateModel);
    }

    @RabbitListener(queues = {TaskConstant.QUEUE_TASK_TIMEOUT_CHECK})
    public void onTimeoutCheckMessage(Long taskId) {
        taskService.processTimeoutCheckMessage(taskId);
    }
}
